package restful.servlet;

import java.util.*;

public class Rules {

	final List<Rule> rules = new LinkedList<Rule>();

	public Rules() {}

	public Rules put(Responder responder, final Class verb, final String pattern) {
		rules.add(new Rule(responder, verb, pattern));
		return this;
	}

	public Responder matches(Class verb, final String requestURI) {
		for (final Rule rule : rules) {
			if (rule.matches(verb, requestURI)) return rule.responder();
		}

		return null;
	}
}
